let http = require('http');
let ejs = require('ejs');

let server = http.createServer((req, res) => {


    let numobj = {
        name: '老王',
        age: '20',
        hobby: [
            '篮球',
            '羽毛球',
            '乒乓球'
        ]
    }



    ejs.renderFile('index.html', numobj, (err, data) => {
        res.setHeader('Content-type', 'text/html;charset=utf-8')
        if (err) {
            res.statusCode = 404;
            res.end('404---网站出错啦' + err.message);
        } else {
            res.end(data.toString())
        }
    })




}).listen(3000, 'www.tb.com', () => {
    console.log('服务器已经打开，请复制域名至浏览器 http://www.tb.com');
})